from objects.login_page import LoginPage


class loginAction:
    def __init__(self, driver):
        self.driver = driver
        self.login_page = LoginPage(driver)
        print("=====开始登录=====")

    def login_prepare(self):
        try:
            self.login_page.myButton_click()
            self.login_page.loginOrRegisterButton_click()
            self.login_page.typeOfLoginButton_click()
        except Exception as e:
            raise '登录准备动作失败' + e

    def login(self, phonenum, password):
        '''
        封装登录动作
        '''
        try:
            self.login_page.phoneTextbox_input(phonenum)
            self.login_page.passwordTextbox_input(password)
            self.login_page.agreeButton_click()
            # self.login_page.loginButton_click()
        except Exception as e:
            raise '登录失败' + e

    def login_after(self):
        try:
            self.login_page.phoneTextbox_clear()
            self.login_page.passwordTextbox_clear()
            self.login_page.agreeButton_click()

        except Exception as e:
            raise '清空操作' + e


